<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Define which configuration should be used
    |--------------------------------------------------------------------------
    */

    'use' => env('RABBITMQ_ENV', 'production'),

    /*
    |--------------------------------------------------------------------------
    | AMQP properties separated by key
    |--------------------------------------------------------------------------
    */

    'properties' => [

        'production' => [
            'host'            => env('RABBITMQ_HOST', 'localhost'),
            'port'            => env('RABBITMQ_PORT', 5672),
            'username'        => env('RABBITMQ_USER', 'guest'),
            'password'        => env('RABBITMQ_PASSWORD', 'guest'),
            'vhost'           => env('RABBITMQ_VHOST', 'datasystem'),
            'connect_options' => [],
            'ssl_options'     => [],

            'exchange'             => 'ds.direct', // 声明一个datasystem交换机
            'exchange_type'        => 'direct',    // 指定交换机类型为topic
            'exchange_passive'     => false,
            'exchange_durable'     => true,       // 交换机保持持久化
            'exchange_auto_delete' => false,
            'exchange_internal'    => false,
            'exchange_nowait'      => false,
            'exchange_properties'  => [],

            'queue_force_declare' => false,
            'queue_passive'       => false,
            'queue_durable'       => true,
            'queue_exclusive'     => false,
            'queue_auto_delete'   => false,
            'queue_nowait'        => false,
            'keepalive'           => true,
            'queue_properties'    => ['x-ha-policy' => ['S', 'all']],
            /*'queue_properties'    => new \PhpAmqpLib\Wire\AMQPTable([
                'arguments1'                => '',
                'arguments2'                => [],
                'x-ha-policy'               => ['S', 'all'],
                // 为队列设置死信交换
                'x-dead-letter-exchange' => env('RABBITMQ_DLX_EXCHANGE', 'dlx.exchange'),
                // 指定死信路由键 (消息被重发的时候, 使用的路由键)
                // 'x-dead-letter-routing-key' => env('RABBITMMQ_DLX_ROUTING_KEY', 'dlx.bindingkey'),
            ]),*/

            'consumer_tag'        => '',
            'consumer_no_local'   => false,
            'consumer_no_ack'     => false,
            'consumer_exclusive'  => false,
            'consumer_nowait'     => false,
            'consumer_properties' => [],
            'timeout'             => 0,
            'persistent'          => true, // required if you want to listen forever
            'publish_timeout'     => 0, // Only applicable when a publish is marked as mandatory
            'qos'                 => true,
            'qos_prefetch_size'   => 0,
            'qos_prefetch_count'  => 10,
            'qos_a_global'        => false,
        ],
    ],
    // 业务相关配置
    'cloud'      => [
        'task' => [
            'add'    => [ // 任务新增
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                'routing_key' => 'task.add',
                'queue'       => 'task.add',
            ],
            'update'    => [ // 任务新增
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                'routing_key' => 'task.update',
                'queue'       => 'task.update',
            ],
            'finish' => [ // 完成任务
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                'routing_key' => 'task.finish',
                'queue'       => 'task.finish',
            ],
            'result-logger-add' => [
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                'routing_key' => 'task.result-logger-add',
                'queue'       => 'task.result-logger-add',
            ],
            'pipeline-abnormal-add' => [
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                'routing_key' => 'task.pipeline-abnormal-add',
                'queue'       => 'task.pipeline-abnormal-add',
            ]
        ],
        'project' => [
            'push' => [
                'net-disk' => [ // 推送项目到网盘
                    'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                    'routing_key' => 'project.push.net-disk',
                    'queue'       => 'project.push.net-disk',
                ],
                'sample'   => [ // 样本
                    'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                    'routing_key' => 'project.push.sample',
                    'queue'       => 'project.push.sample',
                ],
                'contract' => [ // 合同
                    'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                    'routing_key' => 'project.push.contract',
                    'queue'       => 'project.push.contract',
                ],
                'contract-sale-update' => [ // 合同销售
                    'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                    'routing_key' => 'project.push.contract.sale.update',
                    'queue'       => 'project.push.contract.sale.update',
                ],
                'user-add' => [ //项目成员
                    'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                    'routing_key' => 'project.push.user.add',
                    'queue'       => 'project.push.user.add',
                ],
                'contract-op-update' => [ // 运营=项目负责人=项目专员
                    'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                    'routing_key' => 'project.push.contract.op.update',
                    'queue'       => 'project.push.contract.op.update',
                ]
            ]
        ],
        // 回收站
        'recycle' => [
            // 恢复
            'restore' => [
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                'routing_key' => 'recycle.restore',
                'queue'       => 'recycle.restore',
            ]
        ],
        'api-logger' => [
            'add' => [
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
                'routing_key' => 'api-logger.add',
                'queue'       => 'api-logger.add',
            ]
        ],
        'operation_logger' => [ // 增加云平台操作日志
            'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
            'routing_key' => 'ypt.operation.logger',
            'queue'       => 'ypt.operation.logger',
        ],
    ],

    // op系统
    'op' => [
        'task' => [
            'status' => [ // 任务的暂停，重启，停止
                'exchange'    => 'op',
                'routing_key' => 'op.task.status',
                'queue'       => 'op.task.status',
            ]
        ],
        'fx' => [
            'task' => [
                'status' => [ // 共享已完成
                    'exchange'    => 'op',
                    'routing_key' => 'op.fx.task.status',
                    'queue'       => 'op.fx.task.status',
                ]
            ]
        ]
    ],

    'operate-report' => [
        'add' => [
            'tool' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'operate-report'),
                'routing_key' => 'operate-report.add.tool',
                'queue'       => 'operate-report.add.tool',
            ],
            'workflow' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'operate-report'),
                'routing_key' => 'operate-report.add.workflow',
                'queue'       => 'operate-report.add.workflow',
            ],
        ],
        'task' => [
            'pause' => [ // 暂停任务
                'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'operate-report'),
                'routing_key' => 'operate-report.task.pause',
                'queue'       => 'operate-report.task.pause',
            ],
        ]
    ],

    'data' => [
        'add' => [
            'tool' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'data'),
                'routing_key' => 'data.add.tool',
                'queue'       => 'data.add.tool',
            ],
            'workflow' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'data'),
                'routing_key' => 'data.add.workflow',
                'queue'       => 'data.add.workflow',
            ],
            'interaction' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'data'),
                'routing_key' => 'data.add.interaction',
                'queue'       => 'data.add.interaction',
            ],
            'project-file' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'data'),
                'routing_key' => 'data.add.project-file',
                'queue'       => 'data.add.project-file',
            ],
        ],
        'delete' => [
            'dir' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'data'),
                'routing_key' => 'data.delete.dir',
                'queue'       => 'data.delete.dir',
            ],
            'file' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'data'),
                'routing_key' => 'data.delete.file',
                'queue'       => 'data.delete.file',
            ],
        ],
        'download' => [
            'file' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'data'),
                'routing_key' => 'data.download.file',
                'queue'       => 'data.download.file',
            ],
        ],
    ],

    'bio' => [
        'delete' => [
            'task-mongo' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'bio'),
                'routing_key' => 'bio.delete.task-mongo',
                'queue'       => 'bio.delete.task-mongo',
            ],
        ],
    ],

    'analysis' => [
        'auto-run' => [
            'main-task' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'analysis'),
                'routing_key' => 'analysis.auto-run.main-task',
                'queue'       => 'analysis.auto-run.main-task',
            ],
        ],
        'run' => [
            'task' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'analysis'),
                'routing_key' => 'analysis.run.task',
                'queue'       => 'analysis.run.task',
            ],
        ],
        'delete' => [
            'file' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'analysis'),
                'routing_key' => 'analysis.delete.file',
                'queue'       => 'analysis.delete.file',
            ],
            'delay' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'analysis'),
                'routing_key' => 'analysis.delete.delay',
                'queue'       => 'analysis.delete.delay',
            ],
        ],
        'update' => [
            'analysis-delete' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'analysis'),
                'routing_key' => 'analysis.update.analysis-delete',
                'queue'       => 'analysis.update.analysis-delete',
            ],
        ],
    ],

    'mongo-cloud' => [
        'add' => [
            'task-delete' => [
                'exchange'    => env('RABBITMQ_DATA_EXCHANGE', 'mongo-cloud'),
                'routing_key' => 'mongo-cloud.add.task-delete',
                'queue'       => 'mongo-cloud.add.task-delete',
            ],
        ],
    ],

    // 死信队列
    'dlx'  => [
        'exchange'   => env('RABBITMQ_DLX_EXCHANGE', 'dlx.exchange'),
        'cloud_task' => [
            'add'    => [ // 任务新增
                'exchange'    => env('RABBITMQ_DLX_EXCHANGE', 'dlx.exchange'), // 死信交换机可以看做普通交换机
                'queue'       => 'dlx.task.add', // 死信队列可以看做是普通队列
                'routing'     => 'task.add', // 用来绑定死信队列和死信交换机
            ],
            'finish' => [ // 完成任务
                'exchange'    => env('RABBITMQ_DLX_EXCHANGE', 'dlx.exchange'), // 死信交换机可以看做普通交换机
                'queue'       => 'dlx.task.finish', // 死信队列可以看做是普通队列
                'routing'     => 'task.finish', // 用来绑定死信队列和死信交换机
            ],
        ],
        'data' => [
            'delete' => [
                'file' => [
                    'exchange'    => env('RABBITMQ_DLX_EXCHANGE', 'dlx.exchange'),
                    'queue'       => 'dlx.data.delete.file',
                    'routing'     => 'data.delete.file',
                ],
            ]
        ],
        'analysis' => [
            'delete' => [
                'delay' => [
                    'exchange'    => env('RABBITMQ_DLX_EXCHANGE', 'dlx.exchange'),
                    'queue'       => 'dlx.analysis.delete.delay',
                    'routing'     => 'analysis.delete.delay',
                ],
            ]
        ]
    ],
    // 钉钉群机器人异步发消息配置
    'ding' => [
        'exchange'    => 'common',
        'queue'       => 'ding',
        'routing_key' => 'ding.msg',
    ],
    // 发送微信
    'weixin' => [
        'add'    => [ // 新增
            'exchange'    => env('RABBITMQ_CLOUD_EXCHANGE', 'cloud'),
            'routing_key' => 'weixin.add',
            'queue'       => 'weixin.add',
        ]
    ],

];
